package com.suguowen.sblog.mapper;

import com.suguowen.sblog.bean.Tag;
import com.suguowen.sblog.bean.TagExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

public interface TagMapper {
    long countByExample(TagExample example);

    int deleteByExample(TagExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Tag record);

    int insertSelective(Tag record);

    List<Tag> selectByExample(TagExample example);

    @Select("select tag.id,name,count(tag_id) as tagedCount from tag left join article on article.tag_id = tag.id group by tag.id order by tag.id asc")
    @Results({@Result(column="id",property="id"),
            @Result(column="name",property="name"),
            @Result(column="tagedCount",property="tagedArtsCount"),
    })
    List<Tag> select();

    Tag selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Tag record, @Param("example") TagExample example);

    int updateByExample(@Param("record") Tag record, @Param("example") TagExample example);

    int updateByPrimaryKeySelective(Tag record);

    int updateByPrimaryKey(Tag record);
}